﻿using System;
using System.IO;
using System.IO.Pipes;

namespace _025_单向管道通信server
{
    class Program
    {
        static void Main(string[] args)
        {
            using (NamedPipeServerStream 服务器端=new NamedPipeServerStream("zoomla",PipeDirection.Out))
            {

                服务器端.WaitForConnection();

                //使用StreamWriter类来写入信息
                using (StreamWriter 写入操作=new StreamWriter(服务器端))
                {
                    写入操作.AutoFlush = true;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("注意：可输入end退出。");
                    Console.ResetColor();
                    while (true)
                    {
                        Console.WriteLine("请输入要发送的消息：");
                        string 字符串 = Console.ReadLine();
                        if (字符串.ToLower()=="end")
                        {
                            break;
                        }
                        写入操作.WriteLine(字符串);
                        服务器端.WaitForPipeDrain();
                    }
                }
            }
        }
    }
}
